
jQuery.validator.addMethod("checkPassWord",function(value,element){
	if(value.length<6 || value.length>20 ){
		return false;
	}
	return this.optional(element) || !/^[\W_]$/.test(value) && !/^[\d]+$/.test(value) && !/^[A-Za-z]+$/.test(value) && value!=null && value!="";
},"请输入6到20位长的包含字母和数字的密码！");

jQuery.validator.addMethod("checkMail",function(value,element){
	return this.optional(element) || /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z-]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]|net|NET|asia|ASIA|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|cn|CN|cc|CC)$/.test(value);
},"请输入正确的邮箱地址！");

//验证发动机号
jQuery.validator.addMethod("checkMoto", function(value, element) {
	if((value.length>0&&value.length<4) || value.length==4){
		return false;
	}
	var reg =  /^[0-9a-zA-Z-*\s]+$/;
	return this.optional(element) || reg.test(value);
},"请输入正确的发动机号！");
//合作网销系统的车辆信息页面的发动机号验证
jQuery.validator.addMethod("checkMotoForVehicleInfo", function(value, element) {
	if(value.length<4 || value.length==4){
		return false;
	}
	var reg =  /^[0-9a-zA-Z-*\s|\*|\/]+$/;
	return this.optional(element) || reg.test(value);
},"请输入正确的发动机号！");

jQuery.validator.addMethod("mobilePhone",function(value,element){
	var s = value.substr(0,3);
	var condition =  /^(13|14|15|17|18)\d{9}$/.test(value) && s != '170' && s != '171' ;
	return this.optional(element) || condition;
}, "手机号无效或虚拟手机号");

jQuery.validator.addMethod("phoneIns",function(value,element){
	var s = value.substr(0,3);
	var condition =  /^(13|14|15|17|18)\d{9}$/.test(value) && s != '170' && s != '171' ;
	if(!(this.optional(element) || condition)){
		$(".line-height16").hide();
	}else{
		$(".line-height16").show();
	}
	return this.optional(element) || condition;
},"手机号无效或虚拟手机号！");

jQuery.validator.addMethod("checkMailIns",function(value,element){
	if(!(this.optional(element) || /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z-]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]|net|NET|asia|ASIA|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|cn|CN|cc|CC)$/.test(value))){
		$(".line-height-mail").hide();
	}else{
		$(".line-height-mail").show();
	}
	return this.optional(element) || /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z-]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]|net|NET|asia|ASIA|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|cn|CN|cc|CC)$/.test(value);
},"请输入正确的邮箱地址！");

jQuery.validator.addMethod("phone",function(value,element){
	return this.optional(element) || /^(\d{8}|\d{7})$/.test(value);
},"请输入正确的固定电话号码！");

jQuery.validator.addMethod("telephone",function(value,element){
    return this.optional(element) || /^\(?(0\d{2,3}-?)?\)?\d{7,8}$/.test(value);
},"请输入正确的固定电话号码,格式为：(021)12345678或021-12345678或02112345678。");

jQuery.validator.addMethod("regionNum",function(value,element){
	return this.optional(element) || /^0\d{2,3}$/.test(value);
},"请输入正确的区号！");

jQuery.validator.addMethod("carNum",function(value,element){
	if(value.length == 8){
		return this.optional(element) || /^[\u4e00-\u9fa5]([A-Za-z]{1})([DFdf]{1})[\u0000-\u00FF]{5}$/.test(value);
	}else{
		return this.optional(element) || /^[\u4e00-\u9fa5]([A-Za-z]{1})[\u0000-\u00FF]{5}$/.test(value);
	}
},"请输入正确的车牌号码！");

//add by 2017-06-05 at yilan.hu
jQuery.validator.addMethod("new_carNum",function(value,element){
	return this.optional(element) || /^[\u4e00-\u9fa5]([A-Za-z]{1})[\u0000-\u00FF]{5,6}$/.test(value);
},"您输入的车牌不合法！");

//验证身份证
var showErrMsg="身份证号不正确，请重新输入";
jQuery.validator.addMethod("checkIdcard", function(value, element) {
	var idcard = value;
	if(idcard==""){
		return true;
	}
	var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
	
	/*身份号码位数及格式检验*/
	switch (idcard.length) {
	  case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}

		if(regex2.test(idcard)) 
			return true;
		else 
			return false;
		break; 
	  case 18:
	 	 if(regex1.test(idcard)){
			var S = (parseInt(idcard.charAt(0)) + parseInt(idcard.charAt(10))) * 7 + 
                (parseInt(idcard.charAt(1)) + parseInt(idcard.charAt(11))) * 9 + 
                (parseInt(idcard.charAt(2)) + parseInt(idcard.charAt(12))) * 10 + 
                (parseInt(idcard.charAt(3)) + parseInt(idcard.charAt(13))) * 5 + 
                (parseInt(idcard.charAt(4)) + parseInt(idcard.charAt(14))) * 8 + 
                (parseInt(idcard.charAt(5)) + parseInt(idcard.charAt(15))) * 4 + 
                (parseInt(idcard.charAt(6)) + parseInt(idcard.charAt(16))) * 2 + 
                parseInt(idcard.charAt(7)) * 1 + 
                parseInt(idcard.charAt(8)) * 6 + 
                parseInt(idcard.charAt(9)) * 3;
            var Y = S % 11;
			var M = "F";
			var JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			/*判断校验位*/
			if (M == idcard.charAt(17).toUpperCase()) {
	     			//alert(Errors[0]+"18"); 
				return true;
			} else {
				//alert(Errors[3]);
				//showErrMsg = Errors[3];
				return false;
			}
		}else{
			return false;
		}
		break;
	  default:
	  	//alert(Errors[1]);
		//showErrMsg = Errors[1];
		return false;
	}
}, jQuery.validator.format(showErrMsg));

//新续保页面check
jQuery.validator.addMethod("checkIdcardNew", function(value, element) {
	var idcard = value;
	if(idcard==""){
		return true;
	}
	var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
	
	/*身份号码位数及格式检验*/
	switch (idcard.length) {
	  case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}

		if(regex2.test(idcard)) 
			return true;
		else 
			return false;
		break; 
	  case 18:
	 	 if(regex1.test(idcard)){
			var S = (parseInt(idcard.charAt(0)) + parseInt(idcard.charAt(10))) * 7 + 
                (parseInt(idcard.charAt(1)) + parseInt(idcard.charAt(11))) * 9 + 
                (parseInt(idcard.charAt(2)) + parseInt(idcard.charAt(12))) * 10 + 
                (parseInt(idcard.charAt(3)) + parseInt(idcard.charAt(13))) * 5 + 
                (parseInt(idcard.charAt(4)) + parseInt(idcard.charAt(14))) * 8 + 
                (parseInt(idcard.charAt(5)) + parseInt(idcard.charAt(15))) * 4 + 
                (parseInt(idcard.charAt(6)) + parseInt(idcard.charAt(16))) * 2 + 
                parseInt(idcard.charAt(7)) * 1 + 
                parseInt(idcard.charAt(8)) * 6 + 
                parseInt(idcard.charAt(9)) * 3;
            var Y = S % 11;
			var M = "F";
			var JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			/*判断校验位*/
			if (M == idcard.charAt(17).toUpperCase()) {
	     			//alert(Errors[0]+"18"); 
				return true;
			} else {
				//alert(Errors[3]);
				//showErrMsg = Errors[3];
				return false;
			}
		}else{
			return false;
		}
		break;
	  default:
	  	//alert(Errors[1]);
		//showErrMsg = Errors[1];
		return false;
	}
},jQuery.validator.format("证件号错误！"));

//验证身份证
var showRecordErrMsg = "请输入合法的户口薄证件号！";
jQuery.validator.addMethod("checkRecordIdcard", function(value, element) {
	var idcard = value;
	if(idcard==""){
		return true;
	}
	var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
	
	/*身份号码位数及格式检验*/
	switch (idcard.length) {
	  case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}

		if(regex2.test(idcard)) 
			return true;
		else 
			return false;
		break; 
	  case 18:
	 	 if(regex1.test(idcard)){
			var S = (parseInt(idcard.charAt(0)) + parseInt(idcard.charAt(10))) * 7 + 
                (parseInt(idcard.charAt(1)) + parseInt(idcard.charAt(11))) * 9 + 
                (parseInt(idcard.charAt(2)) + parseInt(idcard.charAt(12))) * 10 + 
                (parseInt(idcard.charAt(3)) + parseInt(idcard.charAt(13))) * 5 + 
                (parseInt(idcard.charAt(4)) + parseInt(idcard.charAt(14))) * 8 + 
                (parseInt(idcard.charAt(5)) + parseInt(idcard.charAt(15))) * 4 + 
                (parseInt(idcard.charAt(6)) + parseInt(idcard.charAt(16))) * 2 + 
                parseInt(idcard.charAt(7)) * 1 + 
                parseInt(idcard.charAt(8)) * 6 + 
                parseInt(idcard.charAt(9)) * 3;
            var Y = S % 11;
			var M = "F";
			var JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			/*判断校验位*/
			if (M == idcard.charAt(17).toUpperCase()) {
	     			//alert(Errors[0]+"18"); 
				return true;
			} else {
				//alert(Errors[3]);
				//showErrMsg = Errors[3];
				return false;
			}
		}else{
			return false;
		}
		break;
	  default:
	  	//alert(Errors[1]);
		//showErrMsg = Errors[1];
		return false;
	}
}, jQuery.validator.format(showRecordErrMsg));

//验证驾驶证
var showErrMsg="请输入合法的驾驶证号！";
jQuery.validator.addMethod("checkDriverCardId", function(value, element) {
	var idcard = value;
	if(idcard==""){
		return true;
	}
	var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
	
	/*身份号码位数及格式检验*/
	switch (idcard.length) {
	  case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}

		if(regex2.test(idcard)) 
			return true;
		else 
			return false;
		break; 
	  case 18:
	 	 if(regex1.test(idcard)){
			var S = (parseInt(idcard.charAt(0)) + parseInt(idcard.charAt(10))) * 7 + 
                (parseInt(idcard.charAt(1)) + parseInt(idcard.charAt(11))) * 9 + 
                (parseInt(idcard.charAt(2)) + parseInt(idcard.charAt(12))) * 10 + 
                (parseInt(idcard.charAt(3)) + parseInt(idcard.charAt(13))) * 5 + 
                (parseInt(idcard.charAt(4)) + parseInt(idcard.charAt(14))) * 8 + 
                (parseInt(idcard.charAt(5)) + parseInt(idcard.charAt(15))) * 4 + 
                (parseInt(idcard.charAt(6)) + parseInt(idcard.charAt(16))) * 2 + 
                parseInt(idcard.charAt(7)) * 1 + 
                parseInt(idcard.charAt(8)) * 6 + 
                parseInt(idcard.charAt(9)) * 3;
            var Y = S % 11;
			var M = "F";
			var JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			/*判断校验位*/
			if (M == idcard.charAt(17).toUpperCase()) {
	     			//alert(Errors[0]+"18"); 
				return true;
			} else {
				//alert(Errors[3]);
				//showErrMsg = Errors[3];
				return false;
			}
		}else{
			return false;
		}
		break;
	  default:
	  	//alert(Errors[1]);
		//showErrMsg = Errors[1];
		return false;
	}
}, jQuery.validator.format(showErrMsg));         

//验证百分比
jQuery.validator.addMethod("checkPercent", function(value, element) {
	var reg = /^-?\d+%$/;
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u767e\u5206\u6bd4！");

//验证英文
jQuery.validator.addMethod("checkENG", function(value, element) {
	var reg = /^[a-zA-Z](\s*[a-zA-Z])*$/;
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u82f1\u6587！");

//验证中英文数字
jQuery.validator.addMethod("checkENGCHNNUM", function(value, element) {
	var reg =  /^[0-9a-zA-Z\u4E00-\u9FA5]+$/;
	return this.optional(element) || reg.test(value);
}, "请输入正确的字符或数字！");

//验证中英文 add by ruijie.chen
jQuery.validator.addMethod("checkENGCHN", function(value, element) {
    var reg =  /^[a-zA-Z\u4E00-\u9FA5]+$/;
    return this.optional(element) || reg.test(value);
}, "请输入正确的中文或英文！");

//验证中英文和括号 add by yujia.qian
jQuery.validator.addMethod("checkENGCHNBR", function(value, element) {
    var reg =  /^[a-zA-Z()（）\u4E00-\u9FA5]+$/;
    return this.optional(element) || reg.test(value);
}, "请输入正确的中文或英文或（）符号！");

//验证中英文 add by yinhui.zhou
jQuery.validator.addMethod("checkENGCHNSP", function(value, element) {
    var reg =  /^[ a-zA-Z\u4E00-\u9FA5]+$/;
    return this.optional(element) || reg.test(value);
}, "请输入正确的中文、英文和空格！");

//验证名字是否有效(自然人)  add by 2017/3/28 yilan.hu
jQuery.validator.addMethod("checkName", function(value, element) {
	//统计字符个数
	var lenC = 0;
	//统计中文个数
	var lenCH =  0 ;
    for (var i = 0; i < value.length; i++) {
        var a = value.charAt(i);
        if (a.match(/[\u4e00-\u9fa5]/) != null) {
        	lenC += 2;
        	lenCH += 1;
        }
        else{
        	lenC += 1;
        }
    }
    if(lenCH>25){
    	return false;
    }
	if(value.length<2 || lenC>50){
		return false;
	}
	var reg =  /^([a-zA-Z\u4E00-\u9FA5]·?)+([a-zA-Z\u4E00-\u9FA5]·?)*[a-zA-Z\u4E00-\u9FA5]+$/;
	return this.optional(element) || reg.test(value);
}, "\u59d3\u540d\u8f93\u5165\u6709\u8bef！");

//验证名字是否有效(法人或其他组织)  add by 2017/3/30 yilan.hu
jQuery.validator.addMethod("checkName2", function(value, element) {
	//统计字符个数
	var lenC = 0;
	//统计中文个数
	var lenCH =  0 ;
    for (var i = 0; i < value.length; i++) {
        var a = value.charAt(i);
        if (a.match(/[\u4e00-\u9fa5]/) != null) {
        	lenC += 2;
        	lenCH += 1;
        }
        else{
        	lenC += 1;
        }
    }
    if(lenCH>25){
    	return false;
    }
	if(value.length<2 || lenC>50){
		return false;
	}
	var reg =  /^[a-zA-Z0-9\u4e00-\u9fa5\u300a\u300b]+$/;
	return this.optional(element) || reg.test(value);
}, "\u59d3\u540d\u8f93\u5165\u6709\u8bef!!");


//投保人 被保人  姓名校验
jQuery.validator.addMethod("V_stripscript",function(value, element) {                   
//	var pattern = new RegExp("[~!@#$%^&*+|}{\\\":<>?/;''\\[\\]=`。\\\\]") ; 
//      if(pattern.test(value)){
//    	return false;
//      }
//      return true;
//},"亲，姓名中不能包含特殊字符哦!");
	var reg =  /^([a-zA-Z\u4E00-\u9FA5]·?)+([a-zA-Z\u4E00-\u9FA5]·?)*[a-zA-Z\u4E00-\u9FA5]+$/;
	return this.optional(element) || reg.test(value);
},"亲，姓名输入有误哦！");

//验证英文字母和数字
jQuery.validator.addMethod("checkENGNUM", function(value, element) {
	var reg =  /^[0-9a-zA-Z]+$/;
	return this.optional(element) || reg.test(value);
},"请输入正确的英文字母或数字！");

//验证中文
jQuery.validator.addMethod("checkCHN", function(value, element) {
	// var vehicleDriver = $("#vehicleDriver").val();
	var reg =  /^[\u4e00-\u9fa5]+$/;
	// if(vehicleDriver!="1"){
	// 	reg =  /^[\u4e00-\u9fa5*]+$/;
	// }
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u4e2d\u6587！");

//验证不能为数字
jQuery.validator.addMethod("checkNotNum", function(value, element) {
	var reg =  /(^[^0-9]+$)/;
	return this.optional(element) || reg.test(value);
}, "\u4e0d\u80fd\u586b\u5199\u6570\u5b57！");

//验证大于0的数字
jQuery.validator.addMethod("checkNum", function(value, element) {
	var reg = /^[1-9]+?[0-9]*$/;
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u5927\u4e8e\u96f6\u7684\u6574\u6570！");


//验证小数
jQuery.validator.addMethod("checkFloat", function(value, element) {
	var reg = /^(0|[1-9][0-9]*)(\.[0-9]{1,2})?$/;
	return this.optional(element) || reg.test(value);
}, "请输入小数或者整数！");

//检验是否全为数字
jQuery.validator.addMethod("isNum", function(value, element) {
	var numtype = "0123456789";
	for (i = 0; i < value.length; i++) { //检查是否有不在 0123456789之內的字 
		if (numtype.indexOf(value.charAt(i)) < 0) {
			return false;
		}
	}
	return true;
}, "请输入数字！");

//检验大于0小于5的数字
jQuery.validator.addMethod("isLowFive", function(value, element) {
	var numtype = "1234";
	for (i = 0; i < value.length; i++) { //检查是否有不在 1234之內的字 
		if (numtype.indexOf(value.charAt(i)) < 0) {
			return false;
		}
	}
	if (value<1 || value>5) {
		return false;
	}
	return true;
}, "请输入大于0小于5的正整数！");

//校验24小时时间如： 00:00
jQuery.validator.addMethod("checkTime", function(value, element) {
	var intt = value.indexOf(":");
	var befor = value.substring(0, intt);
	var after = value.substring(intt + 1, intt + 3);
	if (befor >= 24 || befor.length != 2 || after >= 60 || after.length != 2) {
		return false;
	}
	return true;
}, "请输入正确的时间格式，如：00:00！");

//校验Double
jQuery.validator.addMethod("checkDouble", function(value, element) {
	//var reg1 = /^\d+$/;
    var reg = /^(([1-9]\d*(\.\d*[1-9])?)|(0\.\d*[1-9]))$/;  //update by ruijie.chen 2010-03-01
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u6570\u5b57！");

//校验float
jQuery.validator.addMethod("checkFloat", function(value, element) {
	//var reg1 = /^\d+$/;
    var reg = /^\d+(\.\d+)?$/;  //add by yinhui.zhou 2011-08-12
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u5927\u4e8e\u96f6\u7684\u6570\u5b57！");
		
//校验邮政编码
jQuery.validator.addMethod("checkPost", function(value, element) {
	var reg = /^[0-9]\d{5}$/;
	return this.optional(element) || reg.test(value);
}, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u90ae\u653f\u7f16\u7801！");

//校验包含中文字符的字符串的长度，中文每个字符算2个字符长度，英文为1个字符长度
jQuery.validator.addMethod("maxlengthC", function(value, element, param) {
	return this.optional(element) || value.replace(/[^\x00-\xff]/g,"**").length <= param;
}, $.validator.format("允许最大字符为 {0}，每个汉字占2个字符！"));

//校验包含中文字符的字符串的长度，中文每个字符算2个字符长度，英文为1个字符长度
jQuery.validator.addMethod("maxlengthCH", function(value, element, param) {
	return this.optional(element) || value.replace(/[^\x00-\xff]/g,"**").length <= param*2;
}, $.validator.format("最多{0}个汉字。"));

//校验日期 格式：yyyyMM
jQuery.validator.addMethod("date_yyyyMM", function(value, element) {
	return this.optional(element) || /^\d{4}((0[1-9])|(1[0-2])){1}$/.test(value);
}, $.validator.format("请输入正确的日期格式，如：201003"));

//校验日期 格式：yyyy-MM-dd
jQuery.validator.addMethod("date_yyyy-MM-dd", function(value, element) {
	return this.optional(element) || /^\d{4}-\d{2}-\d{2}$/.test(value);
}, $.validator.format("请输入正确的日期格式，如：2010-03-09"));

//校验营销员工号
jQuery.validator.addMethod("checkEmpNo", function(value, element) {
	return this.optional(element) || /^[A-Za-z]{3}[A-Za-z0-9]{2}\d{3}$/.test(value);
}, $.validator.format("工号格式错误"));

// 未来日期校验 add by ruijie.chen 20100406
jQuery.validator.addMethod("futureDateCheck",function(value,element){
	var result = false;
	var newDate = new Date(Date.parse(value.replace(/-/g,"/")));
	if(newDate <= new Date()){
		result = true;
	}
    return this.optional(element) || result;
},"不能填入将来的日期！");

//校验展业证号
jQuery.validator.addMethod("checkCeri", function(value, element) {
	return this.optional(element) || /^\d{18}$/.test(value);
}, $.validator.format("展业证号格式错误"));

//校验密码需由6-16个字符组成，允许出现英文字母、数字或@-_.的符号组合的密码
jQuery.validator.addMethod("checkPwd",function(value,element){
	if (value == '') {
		return false;
	}
//  var _reg = "^[\\w@\\-\\.]{6,16}$";
	var  _reg="^(?!(?:[^a-zA-Z]+|\D+|[a-zA-Z0-9]+)$).{8,20}$";
	var re = new RegExp(_reg);
	if (!re.test(value)) {
		return false;
	}
	return true;
},"密码需由8-20个字符组成，必须包括数字、字母（区分大小写）以及“! # & $”等特殊符号");

//联系方式手机或固定电话
jQuery.validator.addMethod("checkContact",function(value,element){
	var s = value.substr(0,3);
	var condition = /^\(?(0\d{2,3}-?)?\)?\d{7,8}$|(^(13|14|15|17|18)\d{9}$)/.test(value) && s != '170' && s != '171' ;
	return this.optional(element) || condition;
},"无效或虚拟的联系方式！");




//验证身份证
var showErrMsg="请输入正确的身份证！";
jQuery.validator.addMethod("checkIndentNo", function(value, element) {
	var idcard = value;
	if(idcard==""){
		return true;
	}
	var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
	
	/*身份号码位数及格式检验*/
	switch (idcard.length) {
	  case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}

		if(regex2.test(idcard)) 
			return true;
		else 
			return false;
		break; 
	  case 18:
	 	 if(regex1.test(idcard)){
			var S = (parseInt(idcard.charAt(0)) + parseInt(idcard.charAt(10))) * 7 + 
                (parseInt(idcard.charAt(1)) + parseInt(idcard.charAt(11))) * 9 + 
                (parseInt(idcard.charAt(2)) + parseInt(idcard.charAt(12))) * 10 + 
                (parseInt(idcard.charAt(3)) + parseInt(idcard.charAt(13))) * 5 + 
                (parseInt(idcard.charAt(4)) + parseInt(idcard.charAt(14))) * 8 + 
                (parseInt(idcard.charAt(5)) + parseInt(idcard.charAt(15))) * 4 + 
                (parseInt(idcard.charAt(6)) + parseInt(idcard.charAt(16))) * 2 + 
                parseInt(idcard.charAt(7)) * 1 + 
                parseInt(idcard.charAt(8)) * 6 + 
                parseInt(idcard.charAt(9)) * 3;
            var Y = S % 11;
			var M = "F";
			var JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			/*判断校验位*/
			if (M == idcard.charAt(17).toUpperCase()) {
	     			//alert(Errors[0]+"18"); 
				return true;
			} else {
				//alert(Errors[3]);
				//showErrMsg = Errors[3];
				return false;
			}
		}else{
			return false;
		}
		break;
	  default:
	  	//alert(Errors[1]);
		//showErrMsg = Errors[1];
		return false;
	}
}, jQuery.validator.format(showErrMsg));

//扩展了jquery.validte,由于车架号的校验需要,按照基本规则校验
jQuery.validator.addMethod("vinCheck", function(value, element) {
	if (value == "") {
		return false;
	}
	var reg =  /^[A-Z*0-9]{8}([0-9*]||X){1}[A-Z*0-9]{1}[A-Z*0-9]{2}[0-9*]{5}$/;
	var reg2=/(^[^IOQ]+$)/;
	/**校验第十位代码*/
	var reg3=/[^UZ]{1}/;
	return this.optional(element) || (reg.test(value) && reg2.test(value) && value.length == 17 && reg3.test(value.substring(9,10)));
}, "请输入正确的车架号!");

jQuery.validator.addMethod("vinCardCheck", function(value, element) {
//	if (value == "") {
//		return true;
//	}
	var reg =  /^[A-Z*0-9]{8}([0-9*]||X){1}[A-Z*0-9]{1}[A-Z*0-9]{2}[0-9*]{5}$/;
	var reg2=/(^[^IOQ]+$)/;
	/**校验第十位代码*/
	var reg3=/[^UZ]{1}/;
	return this.optional(element) || (reg.test(value) && reg2.test(value) && value.length == 17 && reg3.test(value.substring(9,10)));
}, "请输入正确的车架号!");

//需要填入固定电话或手机
jQuery.validator.addMethod("telOrPhone",function(value,element){
  
	return this.optional(element) || /^(13|14|15|17|18)\d{9}$/.test(value)|| /^\(?(0\d{2,3}-?)?\)?\d{7,8}$/.test(value);
},"请输入固定电话或手机号,电话格式为：(021)12345678或021-12345678或02112345678。");

jQuery.validator.addMethod("carNum1",function(value,element){
	return this.optional(element) || /^[\u4e00-\u9fa5]([A-Z]{1})[A-Z0-9]{5}$/.test(value);
},"请输入正确的车牌号码！");

jQuery.validator.addMethod("checkLicensePlateNo",function(value,element){
	var result = true;
	var lp = new LicensePlate();
	var lpv = $("#province").val();

	var lpNumber = value;
	if (lpNumber != "") {
		var plNo = lp.getLicensePlate(lpv);
		var pxsitPlNo = lpNumber.substr(0, 1);
		if (plNo != pxsitPlNo) {
//			$("#licensePlateNo").focus();
//			alert("不可以异地投保,请重新选择省份或重新填写车牌号");
			result = false;
		}
	}

	return this.optional(element) || result;
},"不可以异地投保,请重新填写车牌号！");

//验证百分比
jQuery.validator.addMethod("checkOneNumber", function(value, element) {
	var reg = /^(?:0|[1-9][0-9]?|100)$/;
	return this.optional(element) || reg.test(value);
}, "请输入0到100的整数！");
//验证手机号和邮箱
jQuery.validator.addMethod("checkMailOrPhone",function(value,element){
	var reg = /^(13|14|15|17|18)\d{9}$/;
	var reg1 = /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z-]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]|net|NET|asia|ASIA|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|cn|CN|cc|CC)$/;
	return this.optional(element) || reg.test(value) || reg1.test(value);
},"请输入正确的邮箱地址或手机号码！");

var showErrMsg="请输入合法的户口薄号！";
jQuery.validator.addMethod("checkRegistered", function(value, element) {
	var idcard = value;
	if(idcard==""){
		return true;
	}
	var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
	
	/*身份号码位数及格式检验*/
	switch (idcard.length) {
	  case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
			var regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}

		if(regex2.test(idcard)) 
			return true;
		else 
			return false;
		break; 
	  case 18:
	 	 if(regex1.test(idcard)){
			var S = (parseInt(idcard.charAt(0)) + parseInt(idcard.charAt(10))) * 7 + 
                (parseInt(idcard.charAt(1)) + parseInt(idcard.charAt(11))) * 9 + 
                (parseInt(idcard.charAt(2)) + parseInt(idcard.charAt(12))) * 10 + 
                (parseInt(idcard.charAt(3)) + parseInt(idcard.charAt(13))) * 5 + 
                (parseInt(idcard.charAt(4)) + parseInt(idcard.charAt(14))) * 8 + 
                (parseInt(idcard.charAt(5)) + parseInt(idcard.charAt(15))) * 4 + 
                (parseInt(idcard.charAt(6)) + parseInt(idcard.charAt(16))) * 2 + 
                parseInt(idcard.charAt(7)) * 1 + 
                parseInt(idcard.charAt(8)) * 6 + 
                parseInt(idcard.charAt(9)) * 3;
            var Y = S % 11;
			var M = "F";
			var JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			/*判断校验位*/
			if (M == idcard.charAt(17).toUpperCase()) {
	     			//alert(Errors[0]+"18"); 
				return true;
			} else {
				//alert(Errors[3]);
				//showErrMsg = Errors[3];
				return false;
			}
		}else{
			return false;
		}
		break;
	  default:
	  	//alert(Errors[1]);
		//showErrMsg = Errors[1];
		return false;
	}
}, jQuery.validator.format(showErrMsg));

//检验大于0小于24的数字
jQuery.validator.addMethod("isHour", function(value, element) {
	var numtype = "0123456789";
	for (var i = 0; i < value.length; i++) { //检查是否有不在 0123456789之內的字 
		if (numtype.indexOf(value.charAt(i)) < 0) {
			return false;
		}
	}
	if (value<0 || value>23) {
		return false;
	}
	return true;
}, "请输入0到23之间的正整数！");

//检验日期格式：只可验证 YYYY-MM-DD ！！！  create by hogntao.ren 2016-12-12
jQuery.validator.addMethod("date_YYYY-MM-DD", function(value, element) {
	 if(value.length!=0){
		var result = value.match(/((^((1[8-9]\d{2})|([2-9]\d{3}))(-)(10|12|0?[13578])(-)(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(11|0?[469])(-)(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(0?2)(-)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)(-)(0?2)(-)(29)$)|(^([3579][26]00)(-)(0?2)(-)(29)$)|(^([1][89][0][48])(-)(0?2)(-)(29)$)|(^([2-9][0-9][0][48])(-)(0?2)(-)(29)$)|(^([1][89][2468][048])(-)(0?2)(-)(29)$)|(^([2-9][0-9][2468][048])(-)(0?2)(-)(29)$)|(^([1][89][13579][26])(-)(0?2)(-)(29)$)|(^([2-9][0-9][13579][26])(-)(0?2)(-)(29)$))/);  
		if(result==null){
        	return false;
        }
		return true;
	 }
	 return true;
}, "格式(YYYY-MM-DD)或日期非法");

/**
 * 校验合理的体重(KG)
 * 不能以0开头, 正数或最多带有两位小数点
 * */
jQuery.validator.addMethod("twoPlacesOfDecimals", function(value, element) {
	var reg = /^(0|[1-9][0-9]*)(\.[0-9]{1,2})?$/;//匹配正float类型的数字
    if(!isNaN(value)){
       return reg.test(value);
    }
    return false;
}, "请输入规范的体重数");

/**
 * 数据非空验证
 */
jQuery.validator.addMethod("dataRequired", function(value, element) {
	if(value==""){
		return false;
	}
	return true;
}, "必填");

jQuery.validator.addMethod("checkFidType", function(value, element) {
	var reg = /^[A-Za-z0-9]+$/;//匹配字母和数字
    return this.optional(element) || reg.test(value);
}, "请输入正确的字母和数字");